static ThreadClosure *
thread_closure_ref (ThreadClosure *thread_closure)
{
+ int refcount;
g_return_val_if_fail (thread_closure != NULL, NULL);
- g_return_val_if_fail (thread_closure->ref_count > 0, NULL);
-
- g_atomic_int_inc (&thread_closure->ref_count);
-
+ refcount = g_atomic_int_add (&thread_closure->ref_count, 1);
+ g_assert (refcount > 0);
return thread_closure;
}
thread_closure_unref (ThreadClosure *thread_closure)
{
g_return_if_fail (thread_closure != NULL);
- g_return_if_fail (thread_closure->ref_count > 0);
if (g_atomic_int_dec_and_test (&thread_closure->ref_count))
{
static OstreeFetcherPendingURI *
pending_uri_ref (OstreeFetcherPendingURI *pending)
{
+ gint refcount;
g_return_val_if_fail (pending != NULL, NULL);
- g_return_val_if_fail (pending->ref_count > 0, NULL);
-
- g_atomic_int_inc (&pending->ref_count);
-
+ refcount = g_atomic_int_add (&pending->ref_count, 1);
+ g_assert (refcount > 0);
return pending;
}
OstreeRepoCommitModifier *
ostree_repo_commit_modifier_ref (OstreeRepoCommitModifier *modifier)
{
- g_atomic_int_inc (&modifier->refcount);
+ gint refcount = g_atomic_int_add (&modifier->refcount, 1);
+ g_assert (refcount > 0);
return modifier;
}
static OstreeRemote *
ost_remote_ref (OstreeRemote *remote)
{
+ gint refcount;
g_return_val_if_fail (remote != NULL, NULL);
- g_return_val_if_fail (remote->ref_count > 0, NULL);
-
- g_atomic_int_inc (&remote->ref_count);
-
+ refcount = g_atomic_int_add (&remote->ref_count, 1);
+ g_assert (refcount > 0);
return remote;
}